######
##
## Choose Data for Territorial Control&Civilian Victimization Coding Exercise
##
######

ged <- read.csv("ged.csv") 

## Subset the Dyads of interest
ged_test <- ged[which(ged$dyad2=="14637" | ged$dyad2=="14620" | ged$dyad2=="11973"),]

## Choose a quarter of events with civilian victimization for the coding exercise 

ged_test$random <- if_else(ged_test$deaths_civilians==0,2,rbinom(13981, 1, 0.25))
write.csv(ged_test, "ged_test.csv")

## Includes coding exercise data
## Also includes territorial control data

ged <- read.csv("ged_main_2024.csv") 

####
##
## Coding Exercise Results
##
####

# Two belligerents fight and civilian death(s) occur
### All
length(ged$random[which(ged$random!=2)])
### Randomly selected sample
length(ged$random[which(ged$random==1)])

# Hand-coded Sample
### All 
length(ged$random[which(ged$random==1)])
### Event source is available online 
length(ged$Test[which(ged$random==1 & ((ged$Test!=2) | is.na(ged$Test)))])
### Event source is available, specifies a location, and a belligerent who killed the civilian(s)
length(ged$Test[which(ged$random==1 & ged$Test!=2)])
### Civilian(s) killed by the dyad member who do not control the territory
length(ged$Test[which(ged$Test==1)])

